package com.ruoyi.project.business.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.business.domain.TgxsNoticeFresh;
import com.ruoyi.project.system.mapper.SysNoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.business.mapper.TgxsNoticeMapper;
import com.ruoyi.project.business.domain.TgxsNotice;
import com.ruoyi.project.business.service.ITgxsNoticeService;

/**
 * 消息通知Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-11-04
 */
@Service
public class TgxsNoticeServiceImpl implements ITgxsNoticeService 
{
    @Autowired
    private TgxsNoticeMapper tgxsNoticeMapper;
    @Autowired
    private SysNoticeMapper noticeMapper;
    /**
     * 查询消息通知
     * 
     * @param id 消息通知ID
     * @return 消息通知
     */
    @Override
    public TgxsNotice selectTgxsNoticeById(Long id)
    {
        return tgxsNoticeMapper.selectTgxsNoticeById(id);
    }

    /**
     * 查询消息通知列表
     * 
     * @param tgxsNotice 消息通知
     * @return 消息通知
     */
    @Override
    public List<TgxsNotice> selectTgxsNoticeList(TgxsNotice tgxsNotice)
    {
        return tgxsNoticeMapper.selectTgxsNoticeList(tgxsNotice);
    }

    /**
     * 新增消息通知
     * 
     * @param tgxsNotice 消息通知
     * @return 结果
     */
    @Override
    public int insertTgxsNotice(TgxsNotice tgxsNotice)
    {
        int a =tgxsNoticeMapper.insertTgxsNotice(tgxsNotice);
        TgxsNoticeFresh tgxsNoticeFresh=new  TgxsNoticeFresh();
        tgxsNoticeFresh.setUserId(tgxsNotice.getReceiverId());
        tgxsNoticeFresh.setIsMsg(1);
        tgxsNoticeFresh.setMsgNoticeId(tgxsNotice.getId());
        tgxsNoticeFresh.setMsgNotice(tgxsNotice.getTitle());
        tgxsNoticeFresh.setMsgNoticeSj(DateUtils.getNowDate());
        noticeMapper.updateTgxsNoticeFreshById(tgxsNoticeFresh);
        return a;
    }

    /**
     * 修改消息通知
     * 
     * @param tgxsNotice 消息通知
     * @return 结果
     */
    @Override
    public int updateTgxsNotice(TgxsNotice tgxsNotice)
    {
        return tgxsNoticeMapper.updateTgxsNotice(tgxsNotice);
    }

    /**
     * 批量删除消息通知
     * 
     * @param ids 需要删除的消息通知ID
     * @return 结果
     */
    @Override
    public int deleteTgxsNoticeByIds(Long[] ids)
    {
        return tgxsNoticeMapper.deleteTgxsNoticeByIds(ids);
    }

    /**
     * 删除消息通知信息
     * 
     * @param id 消息通知ID
     * @return 结果
     */
    @Override
    public int deleteTgxsNoticeById(Long id)
    {
        return tgxsNoticeMapper.deleteTgxsNoticeById(id);
    }
}
